package com.personas.analysic.analyserv.demo;

import org.apache.flink.api.java.DataSet;
import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.api.java.operators.DataSource;
import org.apache.flink.table.api.Table;
import org.apache.flink.table.api.java.BatchTableEnvironment;
import org.apache.flink.types.Row;

public class BatchTest {

    public static void main(String[] args) throws Exception {

        ExecutionEnvironment environment = ExecutionEnvironment.getExecutionEnvironment();

        BatchTableEnvironment batchTableEnvironment = BatchTableEnvironment.create(environment);

        DataSource<String> stringDataSource = environment.fromElements("aaa","aaa","aaa","bbb");

        Table word = batchTableEnvironment.fromDataSet(stringDataSource, "word");

        Table word1 = word.groupBy("word").select("word,count(1) as cun");

        DataSet<Row> rowDataSet = batchTableEnvironment.toDataSet(word1, Row.class);

        rowDataSet.print();

    }
}
